$(function () {
    axios.defaults.baseURL = 'http://www.liulongbin.top:3007'
    let form = layui.form
    form.verify({
        pwd: [/^[\S]{6,15}$/],
        newPwd: function (value) {
            let v1 = $('[name=oldPwd]').val()
            if (value == v1) {
                return '新密码和旧密码不能相同'
            }
        },
        rePwd: function (value) {
            let v2 = $("[name=newPwd]").val()
            if (value == v2) {
                return '两次密码输入不一致'
            }
        }

    })
    $('form').on('submit', function (e) {
        e.preventDefault()
        axios({
            method: 'post',
            url: '/my/updatepwd',
            data: $(this).serialize()
        }).then(res => {
            if (res.data.status != 0) {
                return layui.layer.msg(res.data.message)
            }
            console.log(res);
            layui.layer.msg('恭喜你，修改密码成功！')
            // $('form')[0].reset()
        })
    })
})